home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 140 / Gekkan Dennou Club - 2000.1 Vol. 140 (Japan).7z / Gekkan Dennou Club - 2000.1 Vol. 140 (Japan) (Track 1).bin / tools / dshell / dsh333bs.lzh / gmode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-05  |  3.6 KB  |  235 lines

  1. /*
  2.     dshell    v3
  3.  
  4.     6万色グラフィック表示モード関係 (オリジナル by BEEPs)
  5. */
  6.  
  7. #include    "dsh.h"
  8.  
  9.  
  10. /* gsub.s */
  11. void set_ibit(void);
  12.  
  13.  
  14. void
  15. g_mask(int x, int y, char *mask)
  16. {
  17.     struct TREVPTR buf;
  18.     char *pos;
  19.  
  20.     buf.vram_page = 1;
  21.     buf.x = x * 8;
  22.     buf.y = y * 16;
  23.     buf.x1 = 8;
  24.     buf.y1 = 16;
  25.  
  26.     for (pos = mask; *pos; pos++) {
  27.         if (*pos == '_') {
  28.             TXREV(&buf);
  29.         }
  30.         buf.x += 8;
  31.     }
  32.     return;
  33. }
  34.  
  35.  
  36. void
  37. g_push(int initFlag)
  38. {
  39.     ushort r20;
  40.  
  41.     vsync();
  42.     if (GMODE == 1) {
  43.         CRTMOD(12 + 0x100);
  44.     } else {
  45.         if (CRTMOD(-1) != 12
  46.           || (B_WPEEK(VIDEOR0) & 0x0003) != 0x0003
  47.           || (r20 = B_WPEEK(CRTCR20)) != 0x0315 && r20 != 0x316)
  48.             CRTMOD(12 + 0x100);
  49.         to_square();
  50.     }
  51.     setWidth();
  52. #if 1
  53.     B_LPOKE((unsigned long *)0x95c, 0x00c00000);
  54.     B_LPOKE((unsigned long *)0x960, 0x00000400);
  55.     B_LPOKE((unsigned long *)0x964, 0xffffffff);
  56.     B_LPOKE((unsigned long *)0x968, 0x00000000);
  57.     B_LPOKE((unsigned long *)0x96c, 0x01ff01ff);
  58. #endif
  59.  
  60.     vsync();
  61.     set_ibit();    /* パレットの操作と輝度ビットオン(g_sub.s) */
  62.     noSetIbitFlag = TRUE;
  63.  
  64.     vsync();
  65.     B_WPOKE(VIDEOR1, 0x21E4);    /* プライオリティ TX > GR > SP */
  66.     B_WPOKE(VIDEOR2, 0x1d2F);    /* 半透明 TX & GR */
  67.  
  68.     B_CONSOL(0, 0, 128 - 1, 64 - 1);
  69.     if (initFlag) {
  70.         initPalet();
  71.         Init_Upper_Bar();
  72.         Init_Under_Bar();
  73.         B_COLOR(3);
  74.     }
  75. }
  76.  
  77. /*
  78.     グラフィック画面のみ一時オンにする
  79. */
  80. void
  81. g_pop()
  82. {
  83.     int x, y, r, l;
  84.  
  85.     vsync();
  86.     B_WPOKE(VIDEOR2, 0x000F);    /* 半透明off, TX off, GR on */
  87.  
  88.     /* マウスボタンが押されてるかキー入力があるあいだ */
  89.     do {
  90.         dmsstat(&x, &y, &l, &r);
  91.     } while (l || r || clr_on());
  92.  
  93.     /* マウスボタンが押されるかキー入力があるまで */
  94.     do {
  95.         dmsstat(&x, &y, &l, &r);
  96.     } while (!(l || r || clr_on() || del_on()));
  97.  
  98.     vsync();
  99.     B_WPOKE(VIDEOR2, 0x1d2F);    /* 半透明 TX & GR */
  100.  
  101.     if (del_on()) {    /* v3.10e */
  102.         g_off();
  103.     }
  104.     /* マウスボタンが押されてるかキー入力があるあいだ */
  105.     do {
  106.         dmsstat(&x, &y, &l, &r);
  107.     } while (l || r || clr_on() || del_on());
  108.  
  109. }
  110.  
  111. /*
  112.     グラフィック画面のみ一時消す
  113. */
  114. void
  115. g_off()
  116. {
  117.     int x, y, l, r;
  118.  
  119.     vsync();
  120.     B_WPOKE(VIDEOR2, 0x0020);    /* 半透明off, TX on, GR off */
  121.     do {
  122.         dmsstat(&x, &y, &l, &r);
  123.     } while (l || r || del_on());
  124. }
  125.  
  126. void
  127. g_on()
  128. {
  129.     vsync();
  130.     B_WPOKE(VIDEOR2, 0x1d2f);    /* 半透明 TX & GR */
  131.     wait_mb_off();
  132. }
  133.  
  134. /*
  135.     グラフィック画面表示が ON (TRUE) か OFF (FALSE) かを返す
  136. */
  137. int
  138. g_disp()
  139. {
  140.     if (B_WPEEK(VIDEOR2) & 0x001f) {    /* 0x001f じゃなくて 1 でもいいのか */
  141.         return TRUE;
  142.     } else {
  143.         return FALSE;
  144.     }
  145. }
  146.  
  147.  
  148.  
  149. void 
  150. to_normal()
  151. {
  152.     B_WPOKE(CRTCR20, 0x0315);
  153.     B_WPOKE(CRTCR00, 0x5b);
  154.     B_WPOKE(CRTCR01, 0x09);
  155.     B_WPOKE(CRTCR02, 0x11);
  156.     B_WPOKE(CRTCR03, 0x51);
  157. }
  158.  
  159. void 
  160. to_square()
  161. {
  162.     B_WPOKE(CRTCR00, 0x89);
  163.     B_WPOKE(CRTCR01, 0x0e);
  164.     B_WPOKE(CRTCR02, 0x2c);
  165.     B_WPOKE(CRTCR03, 0x6c);
  166.     B_WPOKE(CRTCR20, 0x0316);
  167. }
  168.  
  169.  
  170. /*
  171.     垂直帰線期間を待つ
  172.  
  173.     void vsync(void);
  174. */
  175. asm("
  176. _vsync::
  177.     suba.l    a1,a1
  178.     moveq.l    #$81,d0
  179.     trap    #15
  180. @@:    btst.b    #4,$e88001
  181.     beq    @b
  182. @@:    btst.b    #4,$e88001
  183.     bne    @b
  184.     tst.l    d0
  185.     bmi    @f
  186.     movea.l    d0,a1
  187.     moveq.l    #$81,d0
  188.     trap    #15
  189. @@:    rts
  190. ");
  191.  
  192.  
  193. /*
  194.     96桁(通常)モード、
  195.     64桁(画像)モードを
  196.     セットする(切り替える)
  197.  
  198.     mode:セットするモード(GMODE)
  199. */
  200. int
  201. set_g_mode(int mode)
  202. {
  203.     mouse(2);
  204.     switch (mode) {
  205.     case 0:
  206.         if (GMODE) {
  207.             vsync();
  208.             B_WPOKE(VIDEOR2, 0);
  209.             C_WIDTH(1);
  210.         }
  211.         break;
  212.     case 1:
  213.     case 2:
  214.         if (!GMODE) {
  215.             vsync();
  216.             B_WPOKE(VIDEOR2, 0);
  217.             C_WIDTH(5);
  218.             noSetIbitFlag = TRUE;
  219.         }
  220.         vsync();
  221.         if (mode == 1)
  222.             to_normal();
  223.         else
  224.             to_square();
  225.         break;
  226.     default:
  227.         return -1;
  228.     }
  229.     GMODE = mode;
  230.     initPalet();
  231.     setWidth();
  232.  
  233.     return 0;
  234. }
  235.